class Solution
{
public:
    int subsetXORSum(vector<int> &nums)
    {
        int result = 0;
        int n = nums.size();
        int total = 1 << n;
        for (int mask = 0; mask < total; ++mask)
        {
            int xorSum = 0;
            for (int i = 0; i < n; ++i)
            {
                if (mask & (1 << i))
                {
                    xorSum ^= nums[i];
                }
            }
            result += xorSum;
        }

        return result;
    }
};